﻿from bs4 import BeautifulSoup

html_content = """  
            <!DOCTYPE html>
            <html>
            <head>
                <title>Sports Video</title>
            </head>
            <body>
            <h1>Sports Video</h1>
            <div class="video-container">
                <video width="100%" height="100%" controls>
                    <source src="sports.mp4" type="video/mp4">
                    Your browser does not support the video tag.
                </video>
            
                <div class="gvp-overlay gvp-layer">11111</div>  
                <div class="gvp-overlay gvp-layer">22222</div>  
                <div class="gvp-overlay gvp-layer">33333</div> 
            </div>
            </body>
            </html>
"""
soup = BeautifulSoup(html_content, 'html.parser')
video_container = soup.find('div', class_='video-container')  # 定位video所在的div容器
video_container.find('video').find_next_sibling('div').decompose()  # 删除第一个div标签

print(soup.prettify())

# if video_tag:  # 如果找到了<video>标签
#     div_tag = video_tag.find_next('div')  # 找到紧跟着的第一个<div>标签
#     print(div_tag)
#
#     if div_tag:  # 如果找到了<div>标签
#         # 移除<div>标签和其内容，并将修改后的HTML内容打印出来
#         pattern = re.compile(str(div_tag), re.S)
#         page_text_param = pattern.sub('', html_content)
#         print(page_text_param)
#     else:
#         print("No <div> tag found after <video> tag.")
# else:
#     print("No <video> tag found in the HTML.")
